Scripting with XML

With the release if IE5, Microsoft fully embraced the W3C standard as regards to DOM support for XML.  Using client-side scripting within HTML pages, you can create very dynamic, robust web applications that utilize XML data on the client, not just the server.  In the next few sections, we are going to discuss DOM support and how you can dynamically create your HTML pages based on XML content.

Before we get into DOM support, there are a couple of key items to understand about client-side scripting.  First of all, always use JavaScript as your client-side scripting language.  JavaScript is the client-side scripting language standard.  JavaScript works with both Internet Explorer and Netscape Navigator, as well as all of the other common browsers available on the Internet today.  Visual Basic Scripting Edition (VBScript) is supported on Internet Explorer only.  Even though we are focusing on IE’s implementation of XML DOM, we are still going to use JavaScript.  Eventually, Netscape will catch up to IE on the XML DOM support side, so we want to write our code to work on both, even if Netscape is currently behind.

Tip:	Always use JavaScript when doing client-side scripting.  
	This will provide better compatibility between browsers 
	now, and in the future.

To follow along with the next few examples, you must be familiar with HTML and JavaScript.  We will go into detail how the code works, but you must already have a basic understanding of HTML and JavaScript and basic programming constructs.

To declare a block on JavaScript code within an HTML document, you must use the <SCRIPT> and </SCRIPT> tags.

<SCRIPT LANGUAGE=”JavaScript”>
<!--
	// Your JavaScript code goes here…
-->
</SCRIPT>

Notice that the code is surrounded by a comment block.  Remember, HTML is not a strict specification like XML.  In fact, if a browser encounters a tag that it does not understand, it ignores it.  While it is not necessary, we always encapsulate our JavaScript within a comment block between the beginning <SCRIPT> and terminating </SCRIPT> tag.  This is a convention which allows JavaScript to be ignored by browsers that do not support it.

Tip:	JavaScript is very similar to Java and C++ in syntax.  For 
	example, most of the syntax is the same, object properties 
	and methods are referenced using the object.identifier 
	syntax, it is a case sensitive language, and statements are 
	terminated with a semicolon (;).  If you are already 
	familiar with Java or C++, JavaScript will be an easy 
	language to learn.